package com.xc.h05.service.renMengBinService.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xc.h05.entity.Publicity;
import com.xc.h05.mapper.PublicityMapper;
import com.xc.h05.service.renMengBinService.PublicityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PublicityServiceImpl implements PublicityService {
    @Autowired
    private PublicityMapper publicityMapper;
    @Override
    public PageInfo<Publicity> selectAll(int pageNum, int pageSize, Publicity publicity) {
        PageHelper.startPage(pageNum, pageSize);
        List<Publicity> list = publicityMapper.selectAll( publicity);
        PageInfo<Publicity> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int add(Publicity publicity) {
        int insert = publicityMapper.insert(publicity);
        return insert;
    }

    @Override
    public int remove(int id) {
        int i = publicityMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public int update(Publicity publicity) {
        int i = publicityMapper.updateByPrimaryKeySelective(publicity);
        return i;
    }

    @Override
    public int removeByScope(List<Integer> id) {
        int i = publicityMapper.deleteByIds(id);
        return i;
    }
}
